package com.heima.jopo.web;

import com.heima.jopo.obj.UserInfo;
import com.heima.jopo.utilconn.GetConn;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Updatexg {

    public void update(UserInfo userInfo, String id) {

        Connection conn = GetConn.getConn();

        String sql = "update t_user_info set id=?,phone=?,passwrod=?,username=?,sex=?,birthday=?,career=? where id=?";

        try {
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setInt(1, Integer.valueOf(id));
            ps.setString(2, userInfo.getPhone());
            ps.setString(3, userInfo.getPasswrod());
            ps.setString(4, userInfo.getUsername());
            ps.setString(5, userInfo.getSex());
            ps.setString(6, userInfo.getBirthday());
            ps.setString(7, userInfo.getCareer());
            ps.setInt(8, Integer.valueOf(id));

            int i = ps.executeUpdate();

            if (i > 0) {
                System.out.println("修改数据成功");
            } else {
                System.out.println("修改数据失败");
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }


    }
}
